"""
存放user应用下所有的celery异步任务

"""
from django.core import mail
from dashopt.celery import app
from utils.sms import YunTongXunAPI
from django.conf import settings


@app.task
def async_send_active_mail(email,verify_url):
    """
    功能函数:发送激活邮件
    :return:
    """
    subject = '达达商城激活邮件'
    html_message = """
    尊敬的用户你好，请点击激活链接进行激活~~~
    <a href="%s" target="_blank">点击此处</a>
    """%verify_url

    mail.send_mail(
        subject=subject,
        message='',
        from_email='1448365754@qq.com',
        recipient_list=[email],
        html_message=html_message,
    )


@app.task
def async_send_message(phone,code):
    sms_api = YunTongXunAPI(**settings.SMS_CONFIG)
    sms_api.run(phone,code)